package book;

public class Book {
    private String name;
    private String author;
    private Integer price;
    private String type;
    private Boolean borrowed;

//提供构造方法
//每一本书初始状态默认未被借出，而borrowed的默认值就是false，因此borrowed可以不作为构造方法参数

    public Book(String name, String author, Integer price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    //提供公开的get和set方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Boolean getBorrowed() {
        return borrowed;
    }

    public void setBorrowed(Boolean borrowed) {
        this.borrowed = borrowed;
    }

//打印这本书需要toString()方法
    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price + ", type='" + type + '\'' +
                ((borrowed == null) ? " 未被借出 " : " 已被借出 ")+
                /*", borrowed=" + borrowed +*/
                '}';
    }
}
